#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "Encoder.h"
#include "Servo.h"

int16_t angle = 0;

int main(void)
{
	OLED_Init();
	Encoder_Init();
	Servo_Init();
	OLED_ShowString(1, 1, "Angle:000");
	while (1)
	{
		angle = Encoder_AngleGet();
		if (angle < 0)
		{
			angle = 0;
			TIM_SetCounter(TIM3, 0);
		}
		if (angle > 100)
		{
			angle = 100;
			TIM_SetCounter(TIM3, 100);
		}	
		OLED_ShowNum(1, 7, angle, 3);
		Servo_AngleSet(angle);
	}
}
